package com.course.business.controller.admin;

import com.course.server.common.Result;
import com.course.server.dto.CourseContentFileDto;
import com.course.server.service.CourseContentFileService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: Durian
 * @date: 2021/5/9 19:19
 */
@RestController
@RequestMapping("/admin/courses/contents/files")
public class CourseContentFileController {

    public static final String BUSINESS_NAME = "课程内容文件";

    @Resource
    private CourseContentFileService courseContentFileService;

    @GetMapping("/{courseId}")
    public Result list(@PathVariable("courseId") String courseId) {
        return Result.success(courseContentFileService.list(courseId));
    }

    @PostMapping
    public Result save(@RequestBody CourseContentFileDto courseContentFileDto) {
        courseContentFileService.save(courseContentFileDto);
        return Result.success(courseContentFileDto);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") String id) {
        courseContentFileService.delete(id);
        return Result.success();
    }
}
